// HSS.Logging.Management.Program.cs
// ----------------------------------------------------------------------------
// Licensed under the MIT license
// http://www.opensource.org/licenses/mit-license.html
// ----------------------------------------------------------------------------
// HighSpeed-Solutions, LLC
// Copyright (c) 2001-2010
// ----------------------------------------------------------------------------
// File:       Program.cs
// Author:     HSS\gbanta
// Created:    08/12/2010
// Modified:   12/04/2010
// ----------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace HSS.Logging.Management
{
	static class Program
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread()]
		static int Main(string[] args)
		{
			AppDomain.CurrentDomain.SetPrincipalPolicy(System.Security.Principal.PrincipalPolicy.WindowsPrincipal);
#if !DEBUG
			new System.Security.Permissions.PrincipalPermission(null, "Administrators").Demand();
#endif
			// If no args, just run the Viewer
			if (args.Length == 0)
			{
				LogViewer.Run(args);
				return 0;
			}
			string[] emptyArgs = new string[] { };

			string logFileOrSwitch = args[0];

			switch (logFileOrSwitch)
			{
				case "-I":
				case "I":
				case "-i":
				case "i":
					DatabaseInstaller.Run();
					break;

				case "-L":
				case "L":
				case "-l":
				case "l":
					ConfigurationEditor.Run();
					break;
				default:
					if (System.IO.File.Exists(logFileOrSwitch))
						LogViewer.Run(args);
					else
						LogViewer.Run(emptyArgs);
					break;
			}

			return 0;

		}
	}
}